


//Treatment variables
gen treatment=0
replace treatment=1 if besco_treatment=="photo"

gen racialtherm=cps19_groups_therm_1
replace racialtherm=racialtherm/100

gen singhtherm=cps19_lead_rating_25
replace singhtherm=singhtherm/100

gen immtherm=cps19_groups_therm_2
replace immtherm=immtherm/100

//White race/ethnicity 
gen white=0
replace white=1 if cps19_ethnicity_24==1
replace white=1 if cps19_ethnicity_26==1
replace white=1 if cps19_ethnicity_27==1
replace white=1 if cps19_ethnicity_28==1
replace white=1 if cps19_ethnicity_29==1
replace white=1 if cps19_ethnicity_30==1
replace white=1 if cps19_ethnicity_34==1
replace white=1 if cps19_ethnicity_35==1
replace white=1 if cps19_ethnicity_37==1
replace white=1 if cps19_ethnicity_38==1
replace white=1 if cps19_ethnicity_39==1
replace white=1 if cps19_ethnicity_40==1

replace white=1 if cps19_ethnicity_41_TEXT=="welsh"
replace white=1 if cps19_ethnicity_41_TEXT=="swiss"
replace white=1 if cps19_ethnicity_41_TEXT=="swedish"
replace white=1 if cps19_ethnicity_41_TEXT=="romanian"
replace white=1 if cps19_ethnicity_41_TEXT=="flemish"
replace white=1 if cps19_ethnicity_41_TEXT=="european"
replace white=1 if cps19_ethnicity_41_TEXT=="english"
replace white=1 if cps19_ethnicity_41_TEXT=="english quebecer"
replace white=1 if cps19_ethnicity_41_TEXT=="belgian"
replace white=1 if cps19_ethnicity_41_TEXT=="Welsh"
replace white=1 if cps19_ethnicity_41_TEXT=="Ukrainian"
replace white=1 if cps19_ethnicity_41_TEXT=="Swiss"
replace white=1 if cps19_ethnicity_41_TEXT=="Swedish"
replace white=1 if cps19_ethnicity_41_TEXT=="Slavic"
replace white=1 if cps19_ethnicity_41_TEXT=="Serbian"
replace white=1 if cps19_ethnicity_41_TEXT=="Scandinave"
replace white=1 if cps19_ethnicity_41_TEXT=="Scandanavian"
replace white=1 if cps19_ethnicity_41_TEXT=="SUISSE"
replace white=1 if cps19_ethnicity_41_TEXT=="Russian"
replace white=1 if cps19_ethnicity_41_TEXT=="Russe"
replace white=1 if cps19_ethnicity_41_TEXT=="Romanian"
replace white=1 if cps19_ethnicity_41_TEXT=="Portuguese"
replace white=1 if cps19_ethnicity_41_TEXT=="Norweigen"
replace white=1 if cps19_ethnicity_41_TEXT=="Norwegian"
replace white=1 if cps19_ethnicity_41_TEXT=="Newfie"
replace white=1 if cps19_ethnicity_41_TEXT=="Lithuian"
replace white=1 if cps19_ethnicity_41_TEXT=="Latvian"
replace white=1 if cps19_ethnicity_41_TEXT=="Jewish"
replace white=1 if cps19_ethnicity_41_TEXT=="Icelandic"
replace white=1 if cps19_ethnicity_41_TEXT=="Greek"
replace white=1 if cps19_ethnicity_41_TEXT=="Finnish"
replace white=1 if cps19_ethnicity_41_TEXT=="European"
replace white=1 if cps19_ethnicity_41_TEXT=="Eastern European"
replace white=1 if cps19_ethnicity_41_TEXT=="Danois"
replace white=1 if cps19_ethnicity_41_TEXT=="Danish"
replace white=1 if cps19_ethnicity_41_TEXT=="Czech"
replace white=1 if cps19_ethnicity_41_TEXT=="Croatian"
replace white=1 if cps19_ethnicity_41_TEXT=="Canadian"
replace white=1 if cps19_ethnicity_41_TEXT=="CANADIAN!"
replace white=1 if cps19_ethnicity_41_TEXT=="British celtic"
replace white=1 if cps19_ethnicity_41_TEXT=="Austrian"
replace white=1 if cps19_ethnicity_41_TEXT=="Australian"
replace white=1 if cps19_ethnicity_41_TEXT=="American"

gen indian=0
replace indian=1 if cps19_ethnicity_32==1



//Create scales of NDP/Singh policy questions
alpha besco_ei_sup_1 besco_ei_good_1 besco_discrim_sup_1 besco_discrim_good_1 besco_pharm_sup_1 besco_pharm_good_1 besco_lang_sup_1 besco_lang_good_1 besco_plastic_sup_1 besco_plastic_good_1, i g(likepolicy)
replace likepolicy=likepolicy/10
alpha besco_ei_good_1  besco_discrim_good_1  besco_pharm_good_1  besco_lang_good_1  besco_plastic_good_1, i g(policygood)
replace policygood=policygood/10
alpha besco_ei_sup_1  besco_discrim_sup_1 besco_pharm_sup_1  besco_lang_sup_1  besco_plastic_sup_1, i g(isupportpolicy)
replace isupportpolicy=isupportpolicy/10

alpha besco_ei_sup_1 besco_ei_good_1 , i g(moreie)
alpha besco_discrim_sup_1 besco_discrim_good_1  , i g(onlinediscrim)
alpha besco_pharm_sup_1 besco_pharm_good_1 , i g(pharm)
alpha besco_lang_sup_1 besco_lang_good_1 , i g(indiglang)
alpha besco_plastic_sup_1 besco_plastic_good_1, i g(plastic)

//More Difficult for Non-Whites difficult for non-whites
gen diffnonwhite=becso_success
replace diffnonwhite=. if becso_success==6
replace diffnonwhite=(diffnonwhite-1)/4

//Minorities Should Be Exempt minorityexempt
gen minorityexempt=becso_exempt
replace minorityexempt=. if becso_exempt==6
replace minorityexempt=(minorityexempt-1)/4

 //Adopt Canadian Values becso_adopt
gen canvalues=becso_adopt
replace canvalues=. if becso_adopt==6
replace canvalues=(canvalues-1)/4

//Immigrants Cost Too Much immcost
gen immcost=becso_benefits
replace immcost=. if becso_benefits==6
replace immcost=(immcost-1)/4

//Many refugees are not real refugees
gen realref=becso_real
replace realref=. if becso_real==6
replace realref=(realref-1)/4



//Demographics and control variables
gen income= cps19_income_cat
replace income=8 if cps19_income_number>200000 & cps19_income_number!=.
replace income=7 if cps19_income_number<=200000 
replace income=6 if cps19_income_number<=150000
replace income=5 if cps19_income_number<=110000
replace income=4 if cps19_income_number<=90000
replace income=3 if cps19_income_number<=60000
replace income=2 if cps19_income_number<=30000
replace income=4.327904 if income==.
replace income=4.327904 if income==9
replace income=(income-1)/7

gen partyID=.
replace partyID=0 if cps19_fed_id==2
replace partyID=1 if cps19_fed_id==1
replace partyID=2 if cps19_fed_id==3
replace partyID=3 if cps19_fed_id==4
replace partyID=4 if cps19_fed_id>4 & cps19_fed_id<8
replace partyID=5 if cps19_fed_id==8
replace partyID=5 if cps19_fed_id==9

label define partyIDl 0 "Conservative" 1 "Liberal" 2 "NDP" 3 "Bloc Quebecois " 4 "Other" 5 "None" 
label values partyID partyIDl 

gen age=2019-cps19_yob

gen man=0
replace man=1 if cps19_gender==1

gen prov=cps19_province

gen unemployed=0
replace unemployed=1 if cps19_employment==5

gen union=0
replace union=1 if cps19_union==1

gen edu=cps19_education
replace edu=. if cps19_education==12

gen interest=cps19_interest_gen_1
replace interest=interest/10

gen media=cps19_news_cons
replace media=. if cps19_news_cons==7
replace media=(media-1)/5
